<template>
  <div style="padding: 20px">
    <el-card>
      <el-form :model="personnelData" inline label-width="100px">
        <el-form-item label="id">
          <el-input
            v-model="personnelData.id"
            placeholder="请输入ID"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="姓名">
          <el-input
            v-model="personnelData.name"
            placeholder="请输入姓名"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="年龄">
          <el-input
            v-model="personnelData.age"
            placeholder="请输入年龄"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="性别">
          <el-select
            v-model="personnelData.sex"
            placeholder="请选择性别"
            clearable
          >
            <el-option
              v-for="item in sexList"
              :key="item.label"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-button type="primary" @click="query" style="margin-left: 100px"
        >查询</el-button
      >
      <el-row>
        <el-col :span="4" :offset="20"> </el-col>
      </el-row>
    </el-card>
    <el-card style="margin-top: 20px">
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="id" label="ID" width="180"> </el-table-column>
        <el-table-column prop="name" label="姓名" width="180">
        </el-table-column>
        <el-table-column prop="age" label="年龄"> </el-table-column>
        <el-table-column prop="sex" label="性别"> </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="text" @click="deletePersonnelOne(scope.row.id)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      personnelData: {
        id: "",
        name: "",
        age: "",
        sex: "",
      },
      sexList: [
        { label: "男", value: "男" },
        { label: "女", value: "女" },
        { label: "其他", value: "其他" },
      ],
      tableData: [
        { id: 1, name: "guoyaohang", age: "23", sex: "男" },
        { id: 2, name: "liuxiaoping", age: "18", sex: "女" },
      ],
    };
  },
  mounted(){
    console.log(this.$store.userName);
  },
  methods: {
    //查询
    query() {
      this.$message.error("测试中功能");
    },
    //删除
    deletePersonnelOne(id) {
      this.$message.success("id:" + id + "删除成功");
    },
  },
};
</script>

<style>
</style>